package com.nest.WorkNest.adapter;

import java.util.ArrayList;

import com.nest.WorkNest.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class TradeAdapter extends BaseAdapter{
	private Context context;
	private ArrayList<String> datalist;
	
	public TradeAdapter(Context context,ArrayList<String> datalist){
		this.context = context;
		this.datalist = datalist;
	}
	@Override
	public int getCount() {
		return datalist.size();
	}

	@Override
	public Object getItem(int position) {
		return datalist.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
	
	private class ViewHolder{
		ImageView image;
		TextView way;
		TextView title;
		TextView add_num;
		TextView money;
		TextView time;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if(convertView == null){
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.trade_item, null);
			holder.image = (ImageView)convertView.findViewById(R.id.image);
			holder.title = (TextView)convertView.findViewById(R.id.title);
			holder.way = (TextView)convertView.findViewById(R.id.way);
			holder.add_num = (TextView)convertView.findViewById(R.id.add_num);
			holder.money = (TextView)convertView.findViewById(R.id.money);
			holder.time = (TextView)convertView.findViewById(R.id.time);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder)convertView.getTag();
		}
		return convertView;
	}

}
